<template>
  <div class="home">
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="id" label="Id" width="100"> </el-table-column>
      <el-table-column prop="title" label="标题" width="200"> </el-table-column>
      <el-table-column prop="detail" label="描述" width="1000">
      </el-table-column>
      <el-table-column prop="price" label="价格"> </el-table-column>
    </el-table>
    <el-pagination layout="prev, pager, next" :total="total"  @current-change="handleCurrentChange"> </el-pagination>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      tableData: [],
      total: 0,
    };
  },
  methods: {
    async http(pageIndex = 0, pageSize = 5) {
      const res = await axios.get("/api/lists", {
        params: {
          pageIndex,
          pageSize,
        },
      });
      this.tableData = res.data.data;
      this.total=res.data.total
      console.log(res);
    },
    handleCurrentChange(index){
      this.http(index)
    }
  },
  created() {
    this.http();
  },
};
</script>
